<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加高峰业务</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../plugins/layui/css/myPage.css">

</head>
<body  >
<div class="layui-container">
    <form class="layui-form">
        <div class="layui-row">
            <fieldset class="layui-elem-field" style="margin-top: 20px;">
                <legend>添加高峰业务</legend>
            <div class="layui-col-md6">


                    <div class="layui-form-item">
                            <label class="layui-form-label"><span style="color: red;">*</span>业务类型</label>
                            <div class="layui-input-inline" >
                                <select name="ywlx" required lay-verify="required"  lay-filter="ywlx">
                                    <option value="">选择业务类型</option>
                                    <option value="顺丰">顺丰</option>
                                    <option value="邮政">邮政</option>
                                    <option value="京东">京东</option>
                                    <option value="其它">其它</option>
                                </select>
                        </div>
                        <div class="layui-input-inline" id="ywqtArea" style="display: none" >
                            <input type="text" name="ywqt" id="ywqt" placeholder="请输入业务类型" class="layui-input"  >
                        </div>
                    </div>
                    <div class="layui-form-item" id="shunfengArea">
                            <label class="layui-form-label" ><span style="color: red;">*</span>区域</label>
                            <div class="layui-input-inline">
                                <div id="quyuSearchContentCon"><select class="layui-input" id="quyu1" lay-search lay-filter="sfqy"> <option value="">请选择</option></select></div>
                            </div>
                        <div class="layui-input-inline" id="qyqtArea1" style="display: none" >
                            <input type="text" id="qyqt1"  placeholder="请输入区域" class="layui-input"  >
                        </div>
                    </div>
                    <div class="layui-form-item" id="youzhengArea" style="display: none">
                        <label class="layui-form-label"><span style="color: red;">*</span>区域</label>
                        <div class="layui-input-inline" >
                            <select id="quyu2" lay-filter="yzqy">
                                <option value="">选择区域</option>
                                <option value="杭州邮政">杭州邮政</option>
                                <option value="宁波邮政">宁波邮政</option>
                                <option value="金华邮政">金华邮政</option>
                                <option value="其它">其它</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" id="qyqtArea2" style="display: none" >
                            <input type="text"id="qyqt2"  placeholder="请输入区域" class="layui-input"  >
                        </div>
                    </div>
                    <div class="layui-form-item" id="jingdongArea" style="display: none">
                        <label class="layui-form-label"><span style="color: red;">*</span>区域</label>
                        <div class="layui-input-inline" >
                            <select id="quyu3" lay-filter="jdqy">
                                <option value="">选择区域</option>
                                <option value="长沙京东">长沙京东</option>
                                <option value="武汉京东">武汉京东</option>
                                <option value="南昌京东">南昌京东</option>
                                <option value="其它">其它</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" id="qyqtArea3" style="display: none" >
                            <input type="text" id="qyqt3"  placeholder="请输入区域" class="layui-input"  >
                        </div>
                    </div>
                <div class="layui-form-item" id="qitaArea" style="display: none">
                    <label class="layui-form-label"><span style="color: red;">*</span>区域</label>
                    <div class="layui-input-inline"  >
                        <input type="text" id="quyu4"  placeholder="请输入区域" class="layui-input"  >
                    </div>
                </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" ><span style="color: red;">*</span>始发地</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="sfd" required lay-verify="required" placeholder="请输入" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" ><span style="color: red;">*</span>目的地</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="mdd"  required lay-verify="required" placeholder="请输入" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" ><span style="color: red;">*</span>靠车时间</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="kcsj" id="kcsj" required lay-verify="required" placeholder="请输入" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" ><span style="color: red;">*</span>出发时间</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="cfsj" id="cfsj" required lay-verify="required" placeholder="请输入" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" ><span style="color: red;">*</span>车标号</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="cbh" required lay-verify="required" placeholder="请输入12位车标号" class="layui-input">
                        </div>
                    </div>
            </div>
            <div class="layui-col-md6">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">*</span>车型</label>
                        <div class="layui-input-inline" >
                            <select name="chexing" required lay-verify="required" lay-filter="chexing" >
                                <option value="">选择车型</option>
                                <option value="30T">30T</option>
                                <option value="20T">20T</option>
                                <option value="14T">14T</option>
                                <option value="7.1T">7.1T</option>
                                <option value="3T">3T</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">*</span>车辆来源</label>
                        <div class="layui-input-inline" >
                            <select name="clly" required lay-verify="required"  lay-filter="clly">
                                <option value="">选择车辆来源</option>
                                <option value="自营车辆">自营车辆</option>
                                <option value="外请车辆">外请车辆</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" id="wqccllyfield" style="display: none">
                            <input type="text" name="wqcclly"  placeholder="请输入车辆来源地" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" ><span style="color: red;">*</span>车牌号</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="cph" required lay-verify="required" placeholder="请输入" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item" id="wgccphfield" style="display: none">
                        <label class="layui-form-label" style="width: 120px"><span style="color: red;">*</span>挂车车牌号</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="wgccph" placeholder="请输入" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" ><span style="color: red;">*</span>驾驶员</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="jsy" required lay-verify="required" placeholder="请输入" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" ><span style="color: red;">*</span>手机号码</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="sjhm" required lay-verify="required" placeholder="请输入" class="layui-input">
                        </div>
                        <div class="layui-input-inline">
                            <div class="layui-input-inline" >
                                <input type="text" name="bysjhm" placeholder="请输入备用手机号" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" id="ykkhfield" style="display: none">
                        <label class="layui-form-label" ><span style="color: red;">*</span>油卡卡号</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="ykkh" placeholder="请输入" class="layui-input">
                        </div>
                    </div>
            </div>
                <div class="layui-col-md12">
                    <div class="layui-form-item">
                        <label class="layui-form-label" >异常备注</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" class="layui-textarea" name="ycbz"></textarea>
                        </div>
                    </div>
                </div>
            </fieldset>
        </div>
        <button id="modiSub" class="layui-btn layui-btn-normal "  lay-submit lay-filter="new" style="width: 10%; position: absolute;left: 45%"  >立即提交</button>
    </form>
</div>
<script src="../plugins/layui/layui.js"></script>
<script src="../js/config.js"></script>
<script src="../js/tools.js"></script>
<script src="../js/autocomplete.js"></script>
<script src="../js/peakarea.js"></script>

<script>
    layui.use(['table','form','layer','laydate'],function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.$;
        var layer = layui.layer;
        var laydate = layui.laydate;

        if(getQueryVariable("C") == "false"){
            $("#new").attr("disabled",true) ;
            $("#new").addClass("layui-btn-disabled");
        }

        //校验
        judgment($,'sjhm',/^\d{11}$/,"请输入正确的手机号码（十一位）");
        judgment($,'cbh',/^\d{12}$/,"请输入正确的车标号（十二位）");
        judgment($,'ykkh',/^\d{8}$/,"请输入正确的油卡卡号（八位）");

        for(var i in quyuArray){
            var option = "<option value='"+ quyuArray[i].value+ "'>"+quyuArray[i].value+"</option>";
            $("#quyu1").append(option);
        };
        form.render('select');

        //日期时间选择器
        laydate.render({
            elem: '#kcsj'
            ,theme:'#0099FF'
            ,type: 'datetime'
            ,value: getFormatDatePeak()
            ,format:'yyyy-MM-dd HH:mm'
        });

        //日期时间选择器
        laydate.render({
            elem: '#cfsj'
            ,theme:'#0099FF'
            ,type: 'datetime'
            ,value: getFormatDatePeak()
            ,format:'yyyy-MM-dd HH:mm'
        });

        // laydate.render({
        //     elem: '#kcsj' //指定元素
        //     ,theme:'#0099FF'
        //     ,value: getFormatDate()
        //     ,type: 'date'
        //     ,format:'yyyy-MM-dd'
        // });

        // laydate.render({
        //     elem: '#cfsj' //指定元素
        //     ,theme:'#0099FF'
        //     ,value: getFormatDate()
        //     ,type: 'date'
        //     ,format:'yyyy-MM-dd'
        // });

        //选择业务类型
        form.on('select(ywlx)',function (data) {
            if(data.value == "顺丰"){
                $("#shunfengArea").show();
                $("#youzhengArea").hide();
                $("#jingdongArea").hide();
                $("#ywqtArea").hide();
            }else if(data.value == "邮政"){
                $("#shunfengArea").hide();
                $("#youzhengArea").show();
                $("#jingdongArea").hide();
                $("#ywqtArea").hide();
            }else if(data.value == "京东"){
                $("#shunfengArea").hide();
                $("#youzhengArea").hide();
                $("#jingdongArea").show();
                $("#ywqtArea").hide();
            }else if(data.value == "其它"){
                $("#shunfengArea").hide();
                $("#youzhengArea").hide();
                $("#jingdongArea").hide();
                $("#qitaArea").show();
                $("#ywqtArea").show();
            }
        });

        //选择顺丰区域
        form.on('select(sfqy)',function (data) {
            if(data.value == "其它"){
                $("#qyqtArea1").show();
                $("#qyqtArea2").hide();
                $("#qyqtArea3").hide();
            }else {
                $("#qyqtArea1").hide();
                $("#qyqtArea2").hide();
                $("#qyqtArea3").hide();
            }
        });

        //选择邮政区域
        form.on('select(yzqy)',function (data) {
            if(data.value == "其它"){
                $("#qyqtArea1").hide();
                $("#qyqtArea2").show();
                $("#qyqtArea3").hide();
            }else {
                $("#qyqtArea1").hide();
                $("#qyqtArea2").hide();
                $("#qyqtArea3").hide();
            }
        });

        //选择京东区域
        form.on('select(jdqy)',function (data) {
            if(data.value == "其它"){
                $("#qyqtArea1").hide();
                $("#qyqtArea2").hide();
                $("#qyqtArea3").show();
            }else {
                $("#qyqtArea1").hide();
                $("#qyqtArea2").hide();
                $("#qyqtArea3").hide();
            }
        });

        //选择车辆来源
        form.on('select(clly)',function (data) {
            if(data.value == "自营车辆"){
                $("#wqccllyfield").hide();
                $("#ykkhfield").hide();
            }else {
                $("#wqccllyfield").show();
                $("#ykkhfield").show();
            }
        });

        //选择车型
        form.on('select(chexing)',function (data) {
            if(data.value == "20T"||data.value == "30T"){
                $("#wgccphfield").show();
            }else {
                $("#wgccphfield").hide();
            }
        });


        form.on('submit(new)', function(data){
            if(data.field.ywlx == '顺丰'){
                data.field.quyu = $("#quyu1").val() ;
                data.field.ywqt = "" ;
            }else if(data.field.ywlx == '邮政'){
                data.field.quyu = $("#quyu2").val() ;
                data.field.ywqt = "" ;
            }else if(data.field.ywlx == '京东'){
                data.field.quyu = $("#quyu3").val() ;
                data.field.ywqt = "" ;
            }else if(data.field.ywlx == '其它'){
                data.field.quyu = $("#quyu4").val() ;
                data.field.ywqt = $("#ywqt").val() ;
            }
            if(data.field.ywlx != '其它'){
               if(data.field.quyu == '其它'){
                   if(data.field.ywlx == '顺丰'){
                       data.field.qyqt = $("#qyqt1").val() ;
                   }else if(data.field.ywlx == '邮政'){
                       data.field.qyqt = $("#qyqt2").val() ;
                   }else if(data.field.ywlx == '京东'){
                       data.field.qyqt = $("#qyqt3").val() ;
                   }
               }
            }
            console.log(data.field);
            $("input").css("border","");
            $.ajax({
                url: contextPath+"/peak",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data: JSON.stringify(data.field) ,
                dataType:"json",
                success: function(res) {
                    updateSuccess($,layer,res)
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });

</script>
</body>
</html>